Disclaimer: all of this is not to be considered medical advice but rather a general explanation. You should talk with your physician and/or pharmacist on a case by case basis when determining whether to take a drug and how to dose it.
We should consider that most pharmaceutical forms are made up from two main components: the active ingredient(s) and the excipients.
The active pharmaceutical ingredient is:
the substance in a pharmaceutical drug or a pesticide that is biologically active.
That is, the part of the drug that actually "does the job". Note that the dosage on the package refer to this, not the weight of the pill! For instance 500mg aspirin will contain 500mg of the active principle (acetylsalicylic acid) but the pill itself will weight more than 500mg.
An excipient is:
an inactive substance formulated alongside the active ingredient ("API") of a medication, for the purpose of bulking-up formulations that contain potent active ingredients (thus often referred to as "bulking agents," "fillers," or "diluents").
This does not normally have biological effects, but allows you, for instance, to have a pill that is of sufficient size to be easy to take in your hand.
When you split a pill in half you are assuming that each half contains the same amount of active ingredient.
This is regulated by the Pharmacopoeia*. In particular when looking at the monograph for tablets we can read (bold is mine):
Tablets are solid dosage forms usually obtained by single or multiple compression of powders or granules. In certain cases tablets may be obtained by moulding or extrusion techniques. They are uncoated or coated.
Tablets are normally right circular solid cylinders, the end surfaces of which are flat or convex and the edges of which may be bevelled. They may have lines or break-marks (scoring), symbols or other markings.
If the break-mark(s) is/are intended to facilitate breaking the tablet for ease of swallowing a dose consisting of one or more whole tablets, the scoring is not critical. However, if the break-mark(s) is/are intended to permit accurate subdivision of the tablet in order to provide doses of less than one tablet, the scoring is critical. Tablets containing active ingredients having a narrow therapeutic window should generally not be presented with break-marks for subdivision. Non-functional break-marks should be avoided.
The point about the therapeutic window shows why splitting pills may be dangerous. The therapeutic window is the range of concentration of a drug which treats disease whilst staying within the safety range.
If this window is narrow, minimal changes in the dose can cause the treatment to be ineffective -if there is too few of the active ingredient- or toxic -if there is too much.
The Pharmacopoeia also lists several tests to be done on tablets. In particular, in the presence of break-marks, the manufacturer should
ensure the effectiveness of break-marks with respect to the uniformity of mass or content, as appropriate, of the subdivided parts so that the patient receives the intended dose.
A suitable test to assess the uniformity of mass during development is as follows:
Take 30 tablets at random. Break each tablet by hand and take one part for the test and reject the other part(s). Weigh each of the 30 parts thus obtained and calculate the average mass. No individual mass is outside the limits of 75% to 125% and not more than one individual mass is outside the limits of 85% to 115% of the average mass.
I will not go into further details, but there are, for instance, other tests to be done to ensure uniformity of mass and content from tablet to tablet, as well as their physical stability (i.e.: they don't have to fall apart in the box).
Note that the packaging should generally include instructions about whether it is safe to split the tablet and how to store (and how long) unused pieces.
This is for splitting tablets. The opposite situation may also arise. Are 2x2mg tablets equivalent to 1x4mg one (speaking of weigth of the active compound in the tablet, not the weight of the tablet itself)? The same reasonings as above apply, however, because tablets should be uniform and no breaking is involved, this is generally safer than the previous case.
All of this applied to a single dose of a drug. Now I would just add a word about repeated doses. I cannot stress this enough: always refer to your physician about drug dosing. Taking a pill in the morning and one in the evening is NOT the same thing as taking two in the morning and none in the evening or taking four halves during the day. Self-dosing is dangerous and should never be done.
Taking half the dose may result in sub-optimal concentration of the drug (so it won't work as expected). Taking twice the dose may result in a toxic peak concentration, which is obviously not something that you want.
* note that there are multiple Pharmacopoeias, and the exact directives may vary. For simplicity I will refer to the International Pharmacopoeia, 4th Edition, 3rd supplement, published by the World Health Organization, and available online. There are others, such as the European Pharmacopoeia (apparently not freely available?) or the Japanese Pharmacopoeia, but I guess that goes beyond the scope of this answer.