I live in the UK and cycle to and from work. I recently noticed that the back brake on the bike is not functioning. Is it legal for me to be cycling on the road (the front brake works fine but it is a bit difficult to stop at, for example, pedestrian crossings)
Most sorts of cycle are required to have at least two efficient braking systems, by which the front wheel (or wheels) can be braked independently of the rear wheel (or wheels).
The likelihood of you receiving a ticket, fine, or other punishment is infinitesimal. It could happen, but it almost certainly will not.
Practically, the front brake is much stronger than the rear brake. Most experienced road cyclists almost exclusively use the front brake. Why is it "a bit difficult to stop" in some circumstances?
That said, you should absolutely have it fixed. Having redundant brakes is important for your personal safety. Brakes and brake cables can fail.
In England and Wales, the relevant legislation is the Pedal Cycles (Construction and Use) Regulations 1983 which say:
7.—(1) ... (a) every pedal cycle shall be equipped with at least one braking system;
(b) every bicycle or tricycle the height of the saddle of which is 635 millimetres or more and every cycle with four or more wheels shall—
(i) if it is so constructed that one or more of the wheels is incapable of rotating independently of the pedals, be equipped with a braking system operating on the front wheel ...;
(ii) if it is not so constructed that one or more of the wheels is incapable of rotating independently of the pedals, be equipped with two independent braking systems one of which operates on the front wheel ..., and the other of which operates on the rear wheel ...
10.—(1) No person shall ride, or cause or permit to be ridden, on a road a pedal cycle ... unless the braking system or systems with which it is required to be fitted ... are in efficient working order.
(I've elided a bunch of exceptions that apply to tricycles, quadricycles, etc.)
So for an ordinary bicycle with a freewheel, it would be a criminal offence to ride it on a road unless you have two braking systems in efficient working order. (See Road Traffic Act 1988 §41A.) But as Stephen Touset says, it would be unheard of for police to check your brakes unless you were involved in a crash.
the front brake works fine but it is a bit difficult to stop
The front brake should be easily sufficient on its own to stop quickly, so it sounds as if your front brake needs adjusting too. For your own safety and the safety of other road users, get your brakes fixed! There are lots of instructional videos out there, or your local bike shop will be happy to do it for you.
Just to note something from another country, in France you must have two brakes:
Tout cycle doit être muni de deux dispositifs de freinage efficaces.
(From the road code, art. R315-3, "All bicycles must have two functioning brakes.")
If you don't have two brakes, you can be fined €11, although usually cops don't care about bikes as long as you're not drunk-riding.
No answer for the original poster, but maybe interesting for readers in Germany:
(1) Alle Fahrzeuge müssen eine ausreichende Bremse haben, die während der Fahrt leicht bedient werden kann und ihre Wirkung erreicht, ohne die Fahrbahn zu beschädigen. Fahrräder müssen zwei voneinander unabhängige Bremsen haben
(1) All vehicles require a sufficient brake, which can be handled easily during the ride/driving and which reaches it impact without damaging the road. Bicycles require two independent brakes.
You must have at least one braking system working to be legal. Coaster bikes only have a rear brake anyway. But what conerns me is your statement that the front brake is working fine, yet you find it difficult to stop at a pedestrian crosing. If the front brake ( the most efficeient brake in most two wheel brake systems due to ther being relatively little weight on the rear wheel ), is working fine, then you should be able to stop very efficiently. You should have to be wary of getting tossed over the handle bars! Therefore, I'd suggest taking time to either replace the brake pads or adjust the system if you're having difficulty stopping. You may save your own skin or that of a pedestrian in a cross walk. Check the wheels and the brake pads to get them both working efficiently. Bicycling is inherently dangerous in some areas anyway, so you must be able to protect yourself and others from getting injured.
Minnesota (USA) law:
(b) No person shall operate a bicycle unless it is equipped with a brake which will enable the operator to make the braked wheels skid on dry, level, clean pavement.
Minnesota Statutes 169,222(b)
This, technically, may disqualify front brakes on standard bikes, since on dry pavement the bike will probably flip before the wheel skids.