Bokmål, initially called Riksmål ('kingdom's language') or sometimes Dano-Norwegian (dansk-norsk), bears a heavy heritage from Danish (as it was spoken in Norway during the time the country was under Danish rule, until 1814). It originates from the formal speech of educated people in greater cities since several centuries.
The Norwegian government adopted together Bokmål (initially called Riksmål) and Nynorsk (initially called Landsmål) in 1885; later in 1929, it gave them their current names.
Each municipality and each school council can choose whether it uses Bokmål or Nynorsk. Nowadays, Bokmål is the majority in the whole of Norway while Nynorsk is preferred in southwestern Norway.