Worked in revenue management for an airline a while back.
Prices depend on historical data, business or leisure route, weekday or weekend, time of travel and if there are any shows/exhibitions/events on in that city at that time. Also what we called "booking curve". ie if its empty at the moment it'll be cheap and if it's nearing full it'll be expensive.
Generally speaking though, the earlier you book the better the price.
Skyscanner is a good one to check.
Pay by credit card in case the carrier goes bankrupt or on strike!