To clarify other people's very good explanations somewhat, the way I think of research is that you need a certain number of research points to get a certain tech. So say you have 10 research a turn; it will take you 10 turns to research a tech which requires 100 points. When you have researched that tech, you will get a certain amount of tech points to trade with other factions; I believe this option is only available however if you have researched more in that Tech than they have. It must be slightly more complicated than that because it's possible for both sides to be able to sell each other tech points in the same area (e.g. Magic). Possibly it's based on you having researched particular techs which they have not. The general point though is that you will not be able to sell any research to factions which have a great deal more research than you. This is on a category basis, so you may not be able to sell any Magic but you may be able to sell Economic points.
When you do sell the points to one AI they seem to immediately disappear as an option to sell to other AIs. I don't know if this is a function of the high difficulty level I play on, a bug, is by design, or is only the case with AIs who are on good terms with each other (and it's assumed they immediately trade with each other).
In terms of what happens when you buy points, this research is now immediately added to your points in that particular area. So in other words if you get ten points in an Economic tech, one which was 100 points will now only take 90 points, and you can research in nine turns rather than ten. However you do not get to choose which tech gets the bonus. I haven't attempted to work out exactly how it's allocated, but it seems to allocate it to one of the earliest un-researched techs in the relevant tree, which may or may not be the one you're currently researching. You can see where the points have been allocated by looking at the research tree, and you will see partially filled in progress bars for techs you have never actually researched. It's generally worth researching these soon, as they will take you less time to research and get the benefits then if you hadn't traded the tech.
My strategy therefore is to trade my tech to the weakest friendly AI who will sell the tech type I'm currently researching; so in other words if I'm researching Economic tech I trade any tech points I have for whatever I can get in Economic tech. I generally try to trade for the same amount of tech as I'm selling, using gold to make up the difference. When I've finished researching my current tech I will probably next research something I got points in from trading.
If you get a "goody hut" which gives you research points (Ancient Library, I think), it allocates those points to the tech you are currently researching, often meaning you research it immediately if you're near the start of the game, which makes it significantly more valuable than tech trading (which is not allocated to the tech you are currently researching). Even given the slightly random nature of tech trading and the bad rate you get though, I still trade it, otherwise I think you get too far behind, especially on higher difficulty levels.