We bought connected flight from Berlin to Palma via London from Ryanair (third party, my trip). We checked on UK.gov website and it said with EU residence permit (Iranian citizen living in Germany) we don't require visa for transit. But now at the airport they are refusing to let us fly and say we need a visa. Is the information on the UK website inaccurate?
You have bought two separate tickets, Ryanair doesn't sell this connection. To be able to check in for the first flight you need to be allowed to enter the UK since that is you destination on the first ticket. From Ryanair's viewpoint your tickets aren't connected and your visit in the UK isn't transit.
The uk.gov site is correct, if the airline would let you fly to the UK the border agents would have let you through with an onward ticket.
The Berlin flight to Stansted airport enters the Common Travel Area, where others on the same flight could continue on to Ireland (or remain in the UK) or, as in your case, travel on to the Schengen Area (together with any domestic UK travelers starting their journey in Stansted).
Passengers from all incoming flights from outside of the Common Travel Area have to go through immigration together, after which the passengers continues on to their respective destinations.
The person I was traveling with (Canadian, with a German permanent residence permit) received a leave to enter for Ireland (which was checked again on arrival at Shannon airport).
For this (returning to the Schengen Area) you would have needed a UK transit visa.
Visa to pass through the UK in transit - GOV.UK
Apply for a Visitor in Transit visa if you’ll be going through UK border control but leaving the UK within 48 hours.
It is the sole responsibility of the passenger to ensure that they have the required documentation needed. The airlines are required to enforce any immigration regulations. Failing to do so would entail, for them, a heavy fine, which they may attempt to pass on to the passenger.