Beagle-eye
You should also provide these details to Ryanair or you will be denied travel.
As to why, the UK is outside the Schengen area and APIS is required by Spain for flights from non Schengen countries.
See this article
Advance Passenger Information Requirements :: Spain and Portugal for Visitors :: The travel guide to Spain and Portugal
Another result of the UK's 'half in half out' approach to Europe.