The purpose of the sample petition for writ of habeas corpus child custody is to seek legal intervention in cases where a child's custody is being wrongfully withheld or denied.