I know what ospf is, but what purpose does it have in th efollowing scenario: an autonomous system has a single router which connects (through access switches) to hosts. The router also connects to another router which acts as the egr, connecting us to another as. The backbone area is the coonnection between the two routers. Is ospf just in use to inform the egr of the routes that the other router knows to hosts in the as?
Pretty much--assuming you are not using BGP and just have a default route to the other AS, you still have to tell your gateway router (let's call it RTA) how to get to your hosts (which are connected to, shall we say, RTB), and RTB needs to know how to get back to RTA as well or your hosts' traffic won't get very far.
Of course all this could technically be accomplished with static routes in both directions, if it will never be more complicated than this. In this scenario you'd want to ask yourself if you will ever grow or need redundancy added in; most will eventually want to do one of these, so designing your network with the robustness that OSPF and BGP provide may be a good idea at the outset--it is not pretty going back and teasing out myriad static routes later.
In the scenario you describe OSPF is the wrong tool and should not be used at all as is would be a waste of resources (CPU cycles/power/administration). You would configure a simple static route.
However, if you insisted on using OSPF in your scenario, all it would do is collect unnecessary details of the far end system (or AS as you call it).
OSPF in networking stands for open shortest path first and is a link state protocol which uses the shortest path first algorithm(SPF) also called as Dijkstra's algorithm to find the best path. OSPF is open standard protocol and so this protocol is currently being used by many vendors including Cisco. This open standard characteristic of OSPF helps in connecting two different routers from different vendors and that makes it very popular and flexible.