Most lenses have filter threads in front of the front element. However, some lenses have filter threads behind the rear element, such as some fisheye lenses b/c the front element protrudes too far forward to place a filter in front of it. What optical consequences would changing the position of the filter have? Would it matter (optically) if a filter is placed behind the rear element of a lens that wasn't originally designed for such placement?
If you put a filter behind the lens, it will change the focus a bit as the converging light rays are refracted as they pass through the filter. (I think it shifts the focal position by about 1/3 the thickness of the filter glass) - This is why many lenses (especially Manual focus ones) that use rear filters usually have a clear filter installed for normal use, to keep the focus in sync with the marked focusing ranges.
This is also why DSLRs modified for astrophotography (by removing the standard infra-red blocking filter, which also blocks a lot of hydrogen-alpha light (the red colour in emission nebulae), usually replace it with a clear or different IR filter rather than just removing the original - if you just remove the original, then because the filter on the sensor is no longer there, the effective focal distance to the sensor changes and no longer matches the separate AF sensor(s) which are set up to match the main sensor + filter combination.
With an AF camera, adding a rear filter affects both the main and AF sensors - so as long as it can still reach focus, you're probably OK - the camera may think the subject distance is different, but that shouldn't normally be a problem.
I have a vague memory that some rear filter lenses didn't come with a clear filter for normal use, but were intended for use with thin gelatine(?) filters - presumably since they're a lot thinner than typical glass ones, the shift is a lot less.
There's no real optical difference if the filter is uniform, clean, and of decent quality.
If the filter is dirty or has large spots that are darker or different colors from other parts of the filter, the further back in the optical chain the filter is placed, the more defined those defects will be in the resulting images when the same aperture is used.
For graduated density filters, the further back in the optical chain, the more defined the transition will be in the resulting photos when the same aperture setting is used.
The reason to have filter inside the lens or behind last element instead of in front is mostly convenience and price. Such construction is used mostly for long telefoto lenses where the front element is very huge (90 or more millimeters) or on wide angle lens where (usually) front element is very curvy and to have filter in front is need to use some filter system with 150mm plates.
Also when you have CP filter or variable ND filter is much more easy to put it inside the lenses (for telefoto) instead of making person to try to reach the front of the lens to turn the dial.