Here's a quick link for changing the speedometer together with a chart to show what speedometer gear tooth count for different tire and axle ratio combinations. http://www.4x4xplor.com/speedo.html
The usual cause however for an inoperative speedometer after reinstalling the speedometer gear housing is the speedometer gear is not engaging the pinion gear underneath inside the transfer case. The reason for that being that the housing was not rotated to the right position, or was not rotated far enough, so the gears mesh together properly. So your fix is very likely that you just need to rotate the gear housing a tad more so the speedometer gear engages its pinion gear underneath.