A lawyer objects when he or she believes that there is question of propriety or legality.
One of the duties of a judge is to decide if the objection is with foundation or inappropriate; thus a judge sustains or overrules it. When a judge sustains an objection, he or she may direct a lawyer to refrain from a line of questioning deemed objectionable.
In jury trials, an objection can result in a direction from the judge that the jury ignore testimony. (This is admittedly difficult to do, and some lawyers test a judge’s forbearance with actions they know will be objectionable.)
Within the limits of the court’s tolerance, lawyers sometimes seek to rattle opposing counsel with frequent -- and sometimes dubious -- objections.
See Courtroom Etiquette; Trial.